package org.huawei260.OD260;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * @Auther: qingle
 * @Date: 2024/8/19-19:32
 * @Description:
 * 给定两个字符串，
 * 从字符串2中找出字符串1中的所有字符，
 * 去重并按照ASCII码值从小到大排列。
 * @version: 1.0
 */
public class O0009_找字符_answer {

	public static void main(String[] args) {

		Scanner sc =  new Scanner(System.in);
		while(sc.hasNext()){
			String str1 = sc.nextLine();
			String str2 = sc.nextLine();
			String res = O0009_找字符_answer.solution(str1,str2);
			System.out.println(res);
		}
	}

	public static String solution(String str1,String str2){
		StringBuilder sb = new StringBuilder();

		char[] chars1 = str1.toCharArray();
		Arrays.sort(chars1);
		char[] chars2 = str2.toCharArray();
		Set<Character> set = new HashSet<>();
		for(char c : chars2){
			if(Arrays.binarySearch(chars1,c)>=0){
				set.add(c);
			}
		}

		for(Character c : set){
			sb.append(c);
		}
		return sb.toString();
	}
}
